package classtest;

import java.util.Scanner;

public class Test4 {
    public static void main(String[] args) {
        //删除指定字符
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入字符串：");
        StringBuffer sb = new StringBuffer(sc.next());
        System.out.println("请输入要删除的字符：");
        String c = sc.next();
        //遍历找出和c相等的字符
        for (int i = 0; i < sb.length(); i++) {
            //获取字符c.charAt(0)就是取出的字符c
            if (sb.charAt(i) == c.charAt(0)) {
                sb.deleteCharAt(i);
                i--;//删除一个字符，i--
            }
        }
        System.out.println(sb);
    }
}
